#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "lzw.cpp"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{
    QString temp = QFileDialog::getOpenFileName(this);
    inFile.setFileName(temp);
    ui->label->setText(temp);
}

void MainWindow::on_pushButton_2_clicked()
{
    QString temp = QFileDialog::getSaveFileName(this);
    outFile.setFileName(temp);
    ui->label_2->setText(temp);
}

void MainWindow::on_pushButton_3_clicked()
{
    if(!inFile.open(QIODevice::ReadOnly))
    {
        qDebug() << "Can't read the file";
    }

    if(!outFile.open(QIODevice::WriteOnly))
    {
        qDebug()<< "Can't write archive";
    }
    //char a[1024];
    /*while(!inFile.atEnd())
    {
        int nBlocksize = inFile.read(a, sizeof(a));
        outFile.write(a, nBlocksize);
    }*/
    CompressFile(inFile, outFile);
}

